package org.i0o.appliancemanager.ui.win;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import org.i0o.appliancemanager.ui.dialog.CreateCardDialog;
import org.springframework.stereotype.Controller;

@Controller
public class MainWin extends BaseWin {

	private static final long	serialVersionUID	= 7150264901458246473L;
	private JMenuItem			menuCreateCard;

	public MainWin() {
	}

	@Override
	protected void initLayout() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void initListener() {
		this.menuCreateCard.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				log.debug("open createcard dialog");
				openCreateCard();
			}
		});
	}

	@Override
	protected void initStyle() {
		this.setExtendedState(JFrame.MAXIMIZED_BOTH);
		this.createMenu();

	}

	private void createMenu() {
		JMenuBar menuBar = new JMenuBar();
		JMenu menuSellManage = new JMenu("销售管理");
		menuBar.add(menuSellManage);

		JMenu menuPurchasesManage = new JMenu("进货管理");
		menuBar.add(menuPurchasesManage);

		JMenu menuMemberManage = new JMenu("会员管理");
		menuBar.add(menuMemberManage);

		this.menuCreateCard = new JMenuItem("发卡");
		menuMemberManage.add(menuCreateCard);

		this.setJMenuBar(menuBar);
	}

	private void openCreateCard() {
		CreateCardDialog createCardWin = new CreateCardDialog(this,true);
		createCardWin.open();
	}

}
